package com.jida.tijian.controller;

import com.jida.tijian.dto.CalendarRequestDto;
import com.jida.tijian.dto.ResponseObject;
import com.jida.tijian.service.CalendarService;
import com.jida.tijian.service.CalendarServiceImpl;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CalendarController {
    //    调用服务层 XXXService xxxservice
    //记得写@Autowired
    @Autowired
    CalendarService calendarService;

    //    写一个响应前端请求的方法
    //    public 返回类型 提供给控制层的方法名（@RequestBody 参数类型 参数名）<-----参数填写后端需要前端的数据传递的数据类型 和对JSON转化@RequestBody
    @RequestMapping("/selectDate")
    public ResponseObject listCalendar(@RequestBody CalendarRequestDto calendarRequestDto) {
        System.out.println("控制层接收前端数据"
                + "医院编号" + calendarRequestDto.getHpId()
                + "\ncurrYear" + calendarRequestDto.getYear()
                + "\ncurrMon" + calendarRequestDto.getMonth());
        //        调用业务层方法 并且 引用业务层 传递业务需要的参数
        //        calendarService.listAppointmentCalendar(calendarRequestDto);
        return new ResponseObject(
                ResponseObject.SUCCESS_STATUS,
                ResponseObject.SUCCESS_DESC,
                calendarService.listAppointmentCalendar(calendarRequestDto)
        );
    }
}
